package com.ap.core.validation.message.rules;

import com.ap.core.cxf.jaxb.paymentdetails.TxnStatusType;
import com.ap.core.message.managepayment.info.ConfirmPaymentRequestMessageInfo;
import com.ap.core.validation.message.info.MessageValidationInfo;
import com.ap.core.validation.message.info.RTPOriginalInfoForConfirmPayment;
import com.ap.core.validation.rules.AbstractValidationRule;

/**
 * User:Rohit.Dixit
 *  FasterPaymentsRef data field must have value if the <TxnStatus> is AUTHORISED in the message
 */
public class IF0012Rule extends AbstractValidationRule<MessageValidationInfo<ConfirmPaymentRequestMessageInfo, RTPOriginalInfoForConfirmPayment>> {

	@Override
	public boolean validate(
			MessageValidationInfo<ConfirmPaymentRequestMessageInfo, RTPOriginalInfoForConfirmPayment> infoObject) {
		boolean pass = true;
		if(infoObject.getBoundObject().getPaymtDetails().getPaymentStatusInfo().getTxnStatus() == TxnStatusType.AUTHORISED){
			return pass = infoObject.getBoundObject().getPaymtDetails().getFasterPaymentsRef() != null;
		}
		return pass;
	}

}

